package chp12;

public class Tool3 {

    public static void main(String[] args) {
        int[] nums = {34,63,2,56,22};
        int[] result = findMaxValueAndMinValue(nums);
        System.out.println("最小值:" + result[0]);
        System.out.println("最大值:" + result[1]);
    }

    public static int[] findMaxValueAndMinValue(int[] arr) {
        int max = arr[0];
        int min = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (arr[i] > max) {
                max = arr[i];
            }
            if(arr[i]<min){
                min = arr[i];
            }
        }
        int[] result = {min,max};
        return result;
    }
}
